import { t } from "@/locales";
import { FormRule, PrimaryTableCol, SelectProps, Space } from "tdesign-vue-next";
import { SearchParamsProps } from "@/components/s-table/type";
import { ClearIcon, Icon } from "tdesign-icons-vue-next";
import { h } from "vue";
/**
 * 搜索表单项
 */
export const searchParams: SearchParamsProps[] = [
    {
        label: t('pages.foodType.title'),
        key: 'title',
    },
];

/**
 * 表格列
 */
export const COLUMNS: PrimaryTableCol[] = [
    {
        title: t('pages.foodType.title'),
        ellipsis: true,
        align: 'center',
        colKey: 'title',
    },
    {
        title: t('pages.foodType.icon'),
        ellipsis: true,
        align: 'center',
        colKey: 'icon',
        cell:(h,{row}) => h(Icon,
            {
                name: row.icon,
                url:ioconfontUrl,
                size:'28px',
            },
        )
    },
    {
        title: t('pages.foodType.remarks'),
        ellipsis: true,
        align: 'center',
        colKey: 'remarks',
    },
];

/**
 * 表单校验规则
 */
export const FORM_RULES: Record<string, FormRule[]> = {
    icon: [{required: true, message: t('pages.foodType.required.icon'), type: 'error', trigger: 'all'}],
}

//阿里巴巴图标矢量库,在https://www.iconfont.cn/的在线链接里面复制JSON文件过来
const iconfontArray ={
        "id": "4767353",
        "name": "sport",
        "font_family": "iconfont",
        "css_prefix_text": "icon-",
        "description": "",
        "glyphs": [
            {
                "icon_id": "5189306",
                "name": "香蕉",
                "font_class": "xiangjiao",
                "unicode": "e605",
                "unicode_decimal": 58885
            },
            {
                "icon_id": "5216611",
                "name": "梨子",
                "font_class": "icon-test",
                "unicode": "e615",
                "unicode_decimal": 58901
            },
            {
                "icon_id": "5216612",
                "name": "西瓜",
                "font_class": "icon-test1",
                "unicode": "e614",
                "unicode_decimal": 58900
            },
            {
                "icon_id": "5216621",
                "name": "菠萝",
                "font_class": "icon-test2",
                "unicode": "e619",
                "unicode_decimal": 58905
            },
            {
                "icon_id": "5216630",
                "name": "柠檬",
                "font_class": "icon-test3",
                "unicode": "e61c",
                "unicode_decimal": 58908
            },
            {
                "icon_id": "9132016",
                "name": "通知",
                "font_class": "tongzhi",
                "unicode": "e628",
                "unicode_decimal": 58920
            },
            {
                "icon_id": "34520528",
                "name": "用户管理",
                "font_class": "yonghuguanli",
                "unicode": "e771",
                "unicode_decimal": 59249
            },
            {
                "icon_id": "37304269",
                "name": "首页",
                "font_class": "shouye",
                "unicode": "e66f",
                "unicode_decimal": 58991
            },
            {
                "icon_id": "39594552",
                "name": "海洋球",
                "font_class": "Sea-Ball-2",
                "unicode": "e63f",
                "unicode_decimal": 58943
            }
        ]
    
}

export const ioconfontUrl = 'https:////at.alicdn.com/t/c/font_4767353_3rlyvfe4e0e.js';
export const iconOptions:SelectProps['options'] = iconfontArray.glyphs.map(i => {
    const value = iconfontArray.css_prefix_text + i.font_class;
    return {
        content: h(Space,{},
            [h(Icon,{url:ioconfontUrl,name:value,size:'large'}),
             h('span',{},i.name)
            ]),
        label: i.name,
        value,
    }
})